package ar.edu.unicen.pladema.vc1.formats.sur;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class SURToken {
	private String fileName = null;
	private InputStream fis = null;
	private boolean hasNext = false;
	private String token = null;

	public SURToken(String fileName) throws IOException {
		this.fileName = fileName;
		this.fis = new FileInputStream(fileName);
		next();
	}
	public boolean hasNext() {
		return hasNext;
	}
	public String next() throws IOException {
		String prev = token;
		StringBuffer sb = new StringBuffer();
		int n = fis.read();
		while ( (n != -1) && (n != 32) && (n != 13) && (n != 10)){
			char c = (char)n;
			sb.append(c);
			n = fis.read();
		}
		hasNext = (n != -1);
		token = sb.toString();
		return prev;
	}
	public void close() {
		if (fis !=null) {
			try {fis.close();} catch(Exception e) {}
		}
	}

}
